package ieco.domaine;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@IdClass(InscriptionPK.class)
@SuppressWarnings("serial")
@Table(schema = "OPTIONS", name = "INSCRIPTIONS")
public class Inscription implements Serializable {

	@Id
	@Column(name = "annee")
	private int annee;

	@Id
	@ManyToOne
	@JoinColumn(name = "ETUDIANT_ID")
	private Etudiant etudiant;

	@Id
	@ManyToOne
	@JoinColumn(name = "OPTIONNEL_ID")
	private Optionnel optionnel;

	// Constructeur vide
	public Inscription() {
	}

	// Constructeur complet
	public Inscription(int annee, Etudiant etudiant_id, Optionnel optionnel_id) {
		super();
		this.annee = annee;
		this.etudiant = etudiant_id;
		this.optionnel = optionnel_id;
	}

	public int getAnnee() {
		return annee;
	}

	public void setAnnee(int annee) {
		this.annee = annee;
	}

	public Etudiant getEtudiant() {
		return etudiant;
	}

	public void setEtudiant(Etudiant etudiant) {
		this.etudiant = etudiant;
	}

	public Optionnel getOptionnel() {
		return optionnel;
	}

	public void setOptionnel(Optionnel optionnel) {
		this.optionnel = optionnel;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + annee;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Inscription other = (Inscription) obj;
		if (annee != other.annee)
			return false;
		return true;
	}

}
